home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 1 (Walnut Creek)
/
Aminet - June 1993 [Walnut Creek].iso
/
aminet
/
dev
/
lang
/
sbp3_1e.lzh
/
AMPERS.PL
< prev
next >
Wrap
Text File
|
1991-10-31
|
847b
|
30 lines
/* From the book PROLOG PROGRAMMING IN DEPTH
by Michael A. Covington, Donald Nute, and Andre Vellino.
Copyright 1988 Scott, Foresman & Co.
Non-commercial distribution of this file is permitted. */
/* Modified for Quintus Prolog by Andreas Siebert */
/* AMPERS.PL */
/* Defines the ampersand (&) as a compound goal constructor,
to avoid the ambiguity created by using commas */
:- op(950,xfy,&). /* syntax of & */
GoalA & GoalB :- call(GoalA),
call(GoalB). /* semantics of & */
/* Knowledge base to demonstrate the ampersand */
parent(michael,cathy).
parent(melody,cathy).
parent(charles_gordon,michael).
parent(hazel,michael).
parent(jim,melody).
parent(eleanor,melody).
grandparent(X,Y) :- parent(Z,Y) & parent(X,Z).
only_child(X) :- parent(P,X) & \+ (parent(P,Z) & Z\==X).